<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>ProctorTicket.Proctor</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="ProctorTicket-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/proctorticket">ProctorTicket</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="ProctorTicket-module.html">Package&nbsp;ProctorTicket</a> ::
        Module&nbsp;Proctor
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="ProctorTicket.Proctor-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="ProctorTicket.Proctor-module.html">Module ProctorTicket.Proctor</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-comment">#  Proctor.py -- Proctor testing for ProctorTicket</tt> </tt>
<a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#  Copyright (C) 2008 Zachary Voase &lt;cracka80@gmail.com&gt;</tt> </tt>
<a name="L3"></a><tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#</tt> </tt>
<a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#  This program is free software; you can redistribute it and/or</tt> </tt>
<a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#  modify it under the terms of the GNU General Public License</tt> </tt>
<a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#  as published by the Free Software Foundation; either version 2</tt> </tt>
<a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#  of the License, or (at your option) any later version.</tt> </tt>
<a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#</tt> </tt>
<a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#  This program is distributed in the hope that it will be useful,</tt> </tt>
<a name="L10"></a><tt class="py-lineno"> 10</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#  but WITHOUT ANY WARRANTY; without even the implied warranty of</tt> </tt>
<a name="L11"></a><tt class="py-lineno"> 11</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</tt> </tt>
<a name="L12"></a><tt class="py-lineno"> 12</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#  GNU General Public License for more details.</tt> </tt>
<a name="L13"></a><tt class="py-lineno"> 13</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#</tt> </tt>
<a name="L14"></a><tt class="py-lineno"> 14</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#  You should have received a copy of the GNU General Public License</tt> </tt>
<a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#  along with this program; if not, write to the Free Software</tt> </tt>
<a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA</tt> </tt>
<a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">#  02110-1301, USA.</tt> </tt>
<a name="L18"></a><tt class="py-lineno"> 18</tt>  <tt class="py-line"><tt class="py-comment"></tt> </tt>
<a name="L19"></a><tt class="py-lineno"> 19</tt>  <tt class="py-line"><tt class="py-docstring">"""ProctorTicket.Proctor:</tt> </tt>
<a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line"><tt class="py-docstring">Library containing the Proctor testing component of the ProctorTicket</tt> </tt>
<a name="L21"></a><tt class="py-lineno"> 21</tt>  <tt class="py-line"><tt class="py-docstring">application. Contains abstractions for running and reading Proctor tests."""</tt> </tt>
<a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line"> </tt>
<a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">proctorlib</tt> </tt>
<a name="L24"></a><tt class="py-lineno"> 24</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">time</tt> </tt>
<a name="L25"></a><tt class="py-lineno"> 25</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt id="link-0" class="py-name" targets="Module ProctorTicket.Utils=ProctorTicket.Utils-module.html"><a title="ProctorTicket.Utils" class="py-name" href="#" onclick="return doclink('link-0', 'Utils', 'link-0');">Utils</a></tt> </tt>
<a name="L26"></a><tt class="py-lineno"> 26</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">popen2</tt> <tt class="py-keyword">import</tt> <tt class="py-name">popen2</tt> </tt>
<a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">os</tt> <tt class="py-keyword">import</tt> <tt class="py-name">getcwdu</tt><tt class="py-op">,</tt> <tt class="py-name">chdir</tt> </tt>
<a name="L28"></a><tt class="py-lineno"> 28</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">proctorlib</tt><tt class="py-op">.</tt><tt class="py-name">result</tt> <tt class="py-keyword">import</tt> <tt class="py-name">ResultFactory</tt><tt class="py-op">,</tt> <tt class="py-name">TestResult</tt> </tt>
<a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">cStringIO</tt> <tt class="py-keyword">import</tt> <tt class="py-name">StringIO</tt> </tt>
<a name="L30"></a><tt class="py-lineno"> 30</tt>  <tt class="py-line"> </tt>
<a name="StatusFilter"></a><div id="StatusFilter-def"><a name="L31"></a><tt class="py-lineno"> 31</tt> <a class="py-toggle" href="#" id="StatusFilter-toggle" onclick="return toggle('StatusFilter');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="ProctorTicket.Proctor-module.html#StatusFilter">StatusFilter</a><tt class="py-op">(</tt><tt class="py-param">status</tt><tt class="py-op">=</tt><tt class="py-op">[</tt><tt class="py-string">'ERROR'</tt><tt class="py-op">,</tt><tt class="py-string">'FAIL'</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="StatusFilter-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="StatusFilter-expanded"><a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line">    <tt class="py-docstring">"""StatusFilter(&lt;iterable&gt;):</tt> </tt>
<a name="L33"></a><tt class="py-lineno"> 33</tt>  <tt class="py-line"><tt class="py-docstring">Returns a filter function, which makes sure that results have one status from</tt> </tt>
<a name="L34"></a><tt class="py-lineno"> 34</tt>  <tt class="py-line"><tt class="py-docstring">the given options. This returns True/False. Used for generating result filters</tt> </tt>
<a name="L35"></a><tt class="py-lineno"> 35</tt>  <tt class="py-line"><tt class="py-docstring">for the Test class."""</tt> </tt>
<a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-keyword">lambda</tt> <tt class="py-name">result</tt><tt class="py-op">:</tt> <tt class="py-name">result</tt><tt class="py-op">.</tt><tt class="py-name">status</tt><tt class="py-op">.</tt><tt class="py-name">lower</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-keyword">in</tt> <tt class="py-op">[</tt> <tt class="py-name">s</tt><tt class="py-op">.</tt><tt class="py-name">lower</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-keyword">for</tt> <tt class="py-name">s</tt> <tt class="py-keyword">in</tt> <tt class="py-name">status</tt> <tt class="py-op">]</tt> </tt>
</div><a name="L37"></a><tt class="py-lineno"> 37</tt>  <tt class="py-line"> </tt>
<a name="Test"></a><div id="Test-def"><a name="L38"></a><tt class="py-lineno"> 38</tt> <a class="py-toggle" href="#" id="Test-toggle" onclick="return toggle('Test');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="ProctorTicket.Proctor.Test-class.html">Test</a><tt class="py-op">(</tt><tt class="py-base-class">object</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Test-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="Test-expanded"><a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line">    <tt class="py-docstring">"""Test(&lt;resultsFilter: StatusFilter(['ERROR', 'FAIL'])&gt;):</tt> </tt>
<a name="L40"></a><tt class="py-lineno"> 40</tt>  <tt class="py-line"><tt class="py-docstring">An object which provides a few wrappings around the use of the Proctor testing</tt> </tt>
<a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line"><tt class="py-docstring">system. Test results can be found in the 'results' attribute, which is a list of</tt> </tt>
<a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line"><tt class="py-docstring">proctorlib.result.TestResult objects. Also includes a 'currentTime' attribute, a</tt> </tt>
<a name="L43"></a><tt class="py-lineno"> 43</tt>  <tt class="py-line"><tt class="py-docstring">datetime() of the time of instantiation of the object, and a 'rawData'</tt> </tt>
<a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line"><tt class="py-docstring">attribute, a file-like object which contains the actual parseable output from</tt> </tt>
<a name="L45"></a><tt class="py-lineno"> 45</tt>  <tt class="py-line"><tt class="py-docstring">'proctorbatch'."""</tt> </tt>
<a name="L46"></a><tt class="py-lineno"> 46</tt>  <tt class="py-line">     </tt>
<a name="L47"></a><tt class="py-lineno"> 47</tt>  <tt class="py-line">    <tt id="link-1" class="py-name" targets="Variable ProctorTicket.Proctor.Test.rawData=ProctorTicket.Proctor.Test-class.html#rawData"><a title="ProctorTicket.Proctor.Test.rawData" class="py-name" href="#" onclick="return doclink('link-1', 'rawData', 'link-1');">rawData</a></tt> <tt class="py-op">=</tt> <tt class="py-name">StringIO</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line">    <tt id="link-2" class="py-name" targets="Variable ProctorTicket.Proctor.Test.currentTime=ProctorTicket.Proctor.Test-class.html#currentTime"><a title="ProctorTicket.Proctor.Test.currentTime" class="py-name" href="#" onclick="return doclink('link-2', 'currentTime', 'link-2');">currentTime</a></tt> <tt class="py-op">=</tt> <tt class="py-name">time</tt><tt class="py-op">.</tt><tt class="py-name">strftime</tt><tt class="py-op">(</tt><tt class="py-string">"%s"</tt><tt class="py-op">)</tt> </tt>
<a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line">     </tt>
<a name="Test.__init__"></a><div id="Test.__init__-def"><a name="L50"></a><tt class="py-lineno"> 50</tt> <a class="py-toggle" href="#" id="Test.__init__-toggle" onclick="return toggle('Test.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="ProctorTicket.Proctor.Test-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">resultsFilter</tt><tt class="py-op">=</tt><tt id="link-3" class="py-name" targets="Function ProctorTicket.Proctor.StatusFilter()=ProctorTicket.Proctor-module.html#StatusFilter"><a title="ProctorTicket.Proctor.StatusFilter" class="py-name" href="#" onclick="return doclink('link-3', 'StatusFilter', 'link-3');">StatusFilter</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-op">*</tt><tt class="py-param">args</tt><tt class="py-op">,</tt> <tt class="py-op">**</tt><tt class="py-param">kwargs</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Test.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Test.__init__-expanded"><a name="L51"></a><tt class="py-lineno"> 51</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">resultslist</tt> <tt class="py-op">=</tt> <tt id="link-4" class="py-name"><a title="ProctorTicket.Utils" class="py-name" href="#" onclick="return doclink('link-4', 'Utils', 'link-0');">Utils</a></tt><tt class="py-op">.</tt><tt id="link-5" class="py-name" targets="Class ProctorTicket.Utils.FilteredList=ProctorTicket.Utils.FilteredList-class.html"><a title="ProctorTicket.Utils.FilteredList" class="py-name" href="#" onclick="return doclink('link-5', 'FilteredList', 'link-5');">FilteredList</a></tt><tt class="py-op">(</tt><tt class="py-name">filterFunction</tt><tt class="py-op">=</tt><tt class="py-name">resultsFilter</tt><tt class="py-op">)</tt> </tt>
<a name="L52"></a><tt class="py-lineno"> 52</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">reader</tt> <tt class="py-op">=</tt> <tt class="py-name">ResultFactory</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">resultslist</tt><tt class="py-op">.</tt><tt id="link-6" class="py-name" targets="Method ProctorTicket.Utils.FilteredList.append()=ProctorTicket.Utils.FilteredList-class.html#append"><a title="ProctorTicket.Utils.FilteredList.append" class="py-name" href="#" onclick="return doclink('link-6', 'append', 'link-6');">append</a></tt><tt class="py-op">)</tt> </tt>
<a name="L53"></a><tt class="py-lineno"> 53</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">resultsDict</tt> <tt class="py-op">=</tt> <tt class="py-op">{</tt><tt class="py-op">}</tt> </tt>
<a name="L54"></a><tt class="py-lineno"> 54</tt>  <tt class="py-line">        <tt class="py-name">object</tt><tt class="py-op">.</tt><tt id="link-7" class="py-name" targets="Method ProctorTicket.Proctor.Test.__init__()=ProctorTicket.Proctor.Test-class.html#__init__,Method ProctorTicket.Trac.TracDBConn.__init__()=ProctorTicket.Trac.TracDBConn-class.html#__init__,Method ProctorTicket.Utils.FilteredList.__init__()=ProctorTicket.Utils.FilteredList-class.html#__init__"><a title="ProctorTicket.Proctor.Test.__init__
ProctorTicket.Trac.TracDBConn.__init__
ProctorTicket.Utils.FilteredList.__init__" class="py-name" href="#" onclick="return doclink('link-7', '__init__', 'link-7');">__init__</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">,</tt> <tt class="py-op">*</tt><tt class="py-name">args</tt><tt class="py-op">,</tt> <tt class="py-op">**</tt><tt class="py-name">kwargs</tt><tt class="py-op">)</tt> </tt>
</div><a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line">     </tt>
<a name="Test.loadFromLog"></a><div id="Test.loadFromLog-def"><a name="L56"></a><tt class="py-lineno"> 56</tt> <a class="py-toggle" href="#" id="Test.loadFromLog-toggle" onclick="return toggle('Test.loadFromLog');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="ProctorTicket.Proctor.Test-class.html#loadFromLog">loadFromLog</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">file_like_object</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Test.loadFromLog-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Test.loadFromLog-expanded"><a name="L57"></a><tt class="py-lineno"> 57</tt>  <tt class="py-line">        <tt class="py-docstring">"""Test.from_file(&lt;file-like object&gt;):</tt> </tt>
<a name="L58"></a><tt class="py-lineno"> 58</tt>  <tt class="py-line"><tt class="py-docstring">Reads data from the file-like object, adds it to the rawData attribute, parses</tt> </tt>
<a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line"><tt class="py-docstring">it and adds results to resultList depending on resultsFilter method."""</tt> </tt>
<a name="L60"></a><tt class="py-lineno"> 60</tt>  <tt class="py-line">        <tt class="py-name">lines</tt> <tt class="py-op">=</tt> <tt class="py-name">file_like_object</tt><tt class="py-op">.</tt><tt class="py-name">readlines</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L61"></a><tt class="py-lineno"> 61</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-8" class="py-name"><a title="ProctorTicket.Proctor.Test.rawData" class="py-name" href="#" onclick="return doclink('link-8', 'rawData', 'link-1');">rawData</a></tt><tt class="py-op">.</tt><tt class="py-name">writelines</tt><tt class="py-op">(</tt><tt class="py-name">lines</tt><tt class="py-op">)</tt> </tt>
<a name="L62"></a><tt class="py-lineno"> 62</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">line</tt> <tt class="py-keyword">in</tt> <tt class="py-name">lines</tt><tt class="py-op">:</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">reader</tt><tt class="py-op">.</tt><tt class="py-name">feed</tt><tt class="py-op">(</tt><tt class="py-name">line</tt><tt class="py-op">)</tt> </tt>
<a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line">        <tt class="py-name">file_like_object</tt><tt class="py-op">.</tt><tt class="py-name">close</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-9" class="py-name" targets="Method ProctorTicket.Proctor.Test.cleanResults()=ProctorTicket.Proctor.Test-class.html#cleanResults"><a title="ProctorTicket.Proctor.Test.cleanResults" class="py-name" href="#" onclick="return doclink('link-9', 'cleanResults', 'link-9');">cleanResults</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">resultslist</tt><tt class="py-op">)</tt> </tt>
<a name="L65"></a><tt class="py-lineno"> 65</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">resultslist</tt> <tt class="py-op">=</tt> <tt id="link-10" class="py-name"><a title="ProctorTicket.Utils" class="py-name" href="#" onclick="return doclink('link-10', 'Utils', 'link-0');">Utils</a></tt><tt class="py-op">.</tt><tt id="link-11" class="py-name"><a title="ProctorTicket.Utils.FilteredList" class="py-name" href="#" onclick="return doclink('link-11', 'FilteredList', 'link-5');">FilteredList</a></tt><tt class="py-op">(</tt><tt class="py-name">filterFunction</tt><tt class="py-op">=</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">resultslist</tt><tt class="py-op">.</tt><tt class="py-name">filterFunction</tt><tt class="py-op">)</tt> </tt>
</div><a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line">     </tt>
<a name="Test.loadFromTest"></a><div id="Test.loadFromTest-def"><a name="L67"></a><tt class="py-lineno"> 67</tt> <a class="py-toggle" href="#" id="Test.loadFromTest-toggle" onclick="return toggle('Test.loadFromTest');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="ProctorTicket.Proctor.Test-class.html#loadFromTest">loadFromTest</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">directory</tt><tt class="py-op">=</tt><tt class="py-name">getcwdu</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Test.loadFromTest-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Test.loadFromTest-expanded"><a name="L68"></a><tt class="py-lineno"> 68</tt>  <tt class="py-line">        <tt class="py-docstring">"""Test.runTest(directory=&lt;string: os.getcwdu()&gt;):</tt> </tt>
<a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line"><tt class="py-docstring">Runs the 'proctorbatch' command line client and gets parseable output for the</tt> </tt>
<a name="L70"></a><tt class="py-lineno"> 70</tt>  <tt class="py-line"><tt class="py-docstring">proctorlib results parser. This output is then processed by loadFromLog in the</tt> </tt>
<a name="L71"></a><tt class="py-lineno"> 71</tt>  <tt class="py-line"><tt class="py-docstring">same way as usual."""</tt> </tt>
<a name="L72"></a><tt class="py-lineno"> 72</tt>  <tt class="py-line">        <tt id="link-12" class="py-name"><a title="ProctorTicket.Utils" class="py-name" href="#" onclick="return doclink('link-12', 'Utils', 'link-0');">Utils</a></tt><tt class="py-op">.</tt><tt id="link-13" class="py-name" targets="Function ProctorTicket.Utils.pushd()=ProctorTicket.Utils-module.html#pushd"><a title="ProctorTicket.Utils.pushd" class="py-name" href="#" onclick="return doclink('link-13', 'pushd', 'link-13');">pushd</a></tt><tt class="py-op">(</tt><tt class="py-name">unicode</tt><tt class="py-op">(</tt><tt class="py-name">directory</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line">        <tt class="py-name">output</tt><tt class="py-op">,</tt> <tt class="py-name">input</tt> <tt class="py-op">=</tt> <tt class="py-name">popen2</tt><tt class="py-op">(</tt><tt class="py-string">"proctorbatch -q --parsable"</tt><tt class="py-op">)</tt> </tt>
<a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line">        <tt class="py-name">data</tt> <tt class="py-op">=</tt> <tt class="py-name">StringIO</tt><tt class="py-op">(</tt><tt class="py-name">output</tt><tt class="py-op">.</tt><tt class="py-name">read</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L75"></a><tt class="py-lineno"> 75</tt>  <tt class="py-line">        <tt class="py-name">output</tt><tt class="py-op">.</tt><tt class="py-name">close</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L76"></a><tt class="py-lineno"> 76</tt>  <tt class="py-line">        <tt class="py-name">input</tt><tt class="py-op">.</tt><tt class="py-name">close</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L77"></a><tt class="py-lineno"> 77</tt>  <tt class="py-line">        <tt id="link-14" class="py-name"><a title="ProctorTicket.Utils" class="py-name" href="#" onclick="return doclink('link-14', 'Utils', 'link-0');">Utils</a></tt><tt class="py-op">.</tt><tt id="link-15" class="py-name" targets="Function ProctorTicket.Utils.popd()=ProctorTicket.Utils-module.html#popd"><a title="ProctorTicket.Utils.popd" class="py-name" href="#" onclick="return doclink('link-15', 'popd', 'link-15');">popd</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L78"></a><tt class="py-lineno"> 78</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-16" class="py-name" targets="Method ProctorTicket.Proctor.Test.loadFromLog()=ProctorTicket.Proctor.Test-class.html#loadFromLog"><a title="ProctorTicket.Proctor.Test.loadFromLog" class="py-name" href="#" onclick="return doclink('link-16', 'loadFromLog', 'link-16');">loadFromLog</a></tt><tt class="py-op">(</tt><tt class="py-name">data</tt><tt class="py-op">)</tt> </tt>
</div><a name="L79"></a><tt class="py-lineno"> 79</tt>  <tt class="py-line">     </tt>
<a name="Test.mergeResultsDict"></a><div id="Test.mergeResultsDict-def"><a name="L80"></a><tt class="py-lineno"> 80</tt> <a class="py-toggle" href="#" id="Test.mergeResultsDict-toggle" onclick="return toggle('Test.mergeResultsDict');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="ProctorTicket.Proctor.Test-class.html#mergeResultsDict">mergeResultsDict</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">dictin</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Test.mergeResultsDict-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Test.mergeResultsDict-expanded"><a name="L81"></a><tt class="py-lineno"> 81</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">key</tt><tt class="py-op">,</tt> <tt class="py-name">value</tt> <tt class="py-keyword">in</tt> <tt class="py-name">dictin</tt><tt class="py-op">.</tt><tt class="py-name">items</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">resultsDict</tt><tt class="py-op">.</tt><tt class="py-name">has_key</tt><tt class="py-op">(</tt><tt class="py-name">key</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">value</tt><tt class="py-op">,</tt> <tt class="py-name">list</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L84"></a><tt class="py-lineno"> 84</tt>  <tt class="py-line">                    <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">resultsDict</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-op">+=</tt> <tt class="py-name">value</tt> </tt>
<a name="L85"></a><tt class="py-lineno"> 85</tt>  <tt class="py-line">                <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line">                    <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">resultsDict</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt id="link-17" class="py-name"><a title="ProctorTicket.Utils.FilteredList.append" class="py-name" href="#" onclick="return doclink('link-17', 'append', 'link-6');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">value</tt><tt class="py-op">)</tt> </tt>
<a name="L87"></a><tt class="py-lineno"> 87</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L88"></a><tt class="py-lineno"> 88</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">value</tt><tt class="py-op">,</tt> <tt class="py-name">list</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L89"></a><tt class="py-lineno"> 89</tt>  <tt class="py-line">                    <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">resultsDict</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">value</tt> </tt>
<a name="L90"></a><tt class="py-lineno"> 90</tt>  <tt class="py-line">                <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L91"></a><tt class="py-lineno"> 91</tt>  <tt class="py-line">                    <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">resultsDict</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt> <tt class="py-name">value</tt> <tt class="py-op">]</tt> </tt>
</div><a name="L92"></a><tt class="py-lineno"> 92</tt>  <tt class="py-line">     </tt>
<a name="Test.cleanResults"></a><div id="Test.cleanResults-def"><a name="L93"></a><tt class="py-lineno"> 93</tt> <a class="py-toggle" href="#" id="Test.cleanResults-toggle" onclick="return toggle('Test.cleanResults');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="ProctorTicket.Proctor.Test-class.html#cleanResults">cleanResults</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">results</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Test.cleanResults-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Test.cleanResults-expanded"><a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line">        <tt class="py-docstring">"""Test.cleanResults(&lt;list&gt;):</tt> </tt>
<a name="L95"></a><tt class="py-lineno"> 95</tt>  <tt class="py-line"><tt class="py-docstring">Goes through the list of TestResult objects, groups together all results from</tt> </tt>
<a name="L96"></a><tt class="py-lineno"> 96</tt>  <tt class="py-line"><tt class="py-docstring">the same test class into lists, removes duplicated entries and then uses </tt> </tt>
<a name="L97"></a><tt class="py-lineno"> 97</tt>  <tt class="py-line"><tt class="py-docstring">'mergeResultsDict' method to place all test class result lists into</tt> </tt>
<a name="L98"></a><tt class="py-lineno"> 98</tt>  <tt class="py-line"><tt class="py-docstring">'resultsDict' attribute."""</tt> </tt>
<a name="L99"></a><tt class="py-lineno"> 99</tt>  <tt class="py-line">        <tt class="py-name">dictOut</tt> <tt class="py-op">=</tt> <tt class="py-op">{</tt><tt class="py-op">}</tt> </tt>
<a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line">        <tt class="py-name">uniqueResults</tt> <tt class="py-op">=</tt> <tt id="link-18" class="py-name"><a title="ProctorTicket.Utils" class="py-name" href="#" onclick="return doclink('link-18', 'Utils', 'link-0');">Utils</a></tt><tt class="py-op">.</tt><tt id="link-19" class="py-name" targets="Function ProctorTicket.Utils.UniquifyResults()=ProctorTicket.Utils-module.html#UniquifyResults"><a title="ProctorTicket.Utils.UniquifyResults" class="py-name" href="#" onclick="return doclink('link-19', 'UniquifyResults', 'link-19');">UniquifyResults</a></tt><tt class="py-op">(</tt><tt class="py-name">results</tt><tt class="py-op">)</tt> </tt>
<a name="L101"></a><tt class="py-lineno">101</tt>  <tt class="py-line">        <tt class="py-name">classNames</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt> <tt id="link-20" class="py-name"><a title="ProctorTicket.Utils" class="py-name" href="#" onclick="return doclink('link-20', 'Utils', 'link-0');">Utils</a></tt><tt class="py-op">.</tt><tt id="link-21" class="py-name" targets="Function ProctorTicket.Utils.GetTestClass()=ProctorTicket.Utils-module.html#GetTestClass"><a title="ProctorTicket.Utils.GetTestClass" class="py-name" href="#" onclick="return doclink('link-21', 'GetTestClass', 'link-21');">GetTestClass</a></tt><tt class="py-op">(</tt><tt class="py-name">res</tt><tt class="py-op">)</tt> <tt class="py-keyword">for</tt> <tt class="py-name">res</tt> <tt class="py-keyword">in</tt> <tt class="py-name">uniqueResults</tt> <tt class="py-op">]</tt> </tt>
<a name="L102"></a><tt class="py-lineno">102</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">i</tt> <tt class="py-keyword">in</tt> <tt class="py-name">range</tt><tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">uniqueResults</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">dictOut</tt><tt class="py-op">.</tt><tt class="py-name">has_key</tt><tt class="py-op">(</tt><tt class="py-name">classNames</tt><tt class="py-op">[</tt><tt class="py-name">i</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line">                <tt class="py-name">dictOut</tt><tt class="py-op">[</tt><tt class="py-name">classNames</tt><tt class="py-op">[</tt><tt class="py-name">i</tt><tt class="py-op">]</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt id="link-22" class="py-name"><a title="ProctorTicket.Utils.FilteredList.append" class="py-name" href="#" onclick="return doclink('link-22', 'append', 'link-6');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">uniqueResults</tt><tt class="py-op">[</tt><tt class="py-name">i</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L105"></a><tt class="py-lineno">105</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line">                <tt class="py-name">dictOut</tt><tt class="py-op">[</tt><tt class="py-name">classNames</tt><tt class="py-op">[</tt><tt class="py-name">i</tt><tt class="py-op">]</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt> <tt class="py-name">uniqueResults</tt><tt class="py-op">[</tt><tt class="py-name">i</tt><tt class="py-op">]</tt> <tt class="py-op">]</tt> </tt>
<a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-23" class="py-name" targets="Method ProctorTicket.Proctor.Test.mergeResultsDict()=ProctorTicket.Proctor.Test-class.html#mergeResultsDict"><a title="ProctorTicket.Proctor.Test.mergeResultsDict" class="py-name" href="#" onclick="return doclink('link-23', 'mergeResultsDict', 'link-23');">mergeResultsDict</a></tt><tt class="py-op">(</tt><tt class="py-name">dictOut</tt><tt class="py-op">)</tt> </tt>
</div></div><a name="L108"></a><tt class="py-lineno">108</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="ProctorTicket-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/proctorticket">ProctorTicket</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0beta1 on Sat Jan 19 19:26:41 2008
    </td>
    <td align="right" class="footer">
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie()
  // -->
</script>
  
</body>
</html>
